package org.sction.bean;

import java.io.File;

import org.sction.util.FileUtils;


/**
 * @author 作者 : sorc
 * @version 创建时间：2012-3-20 下午4:06:33
 * 
 *          类说明
 */
public class FileBean {
	private String name = null;
	private String mimeType = "application/x-msdownload;";
	private boolean stream = false;
	private String nameEncoding = "UTF-8";
	private String path = null;
	private byte[] bin = null;
	private String suffix = null;
	private long length = -1;
	private File file = null;
	private String msg = null;
	private boolean down = true;

	public FileBean(String path) {
		this.setPath(path);
	}

	public FileBean(String path, String name) {
		this.setName(name);
		this.setPath(path);
	}

	public FileBean(byte[] bin, String name) {
		this.setName(name);
		this.bin = bin;
	}

	public void setPath(String path) {
		this.path = path;
		if (this.name == null)
			this.name = FileUtils.getFileSimpleName(this.path);
		else
			this.name = FileUtils.getFileSimpleName(this.name);
		this.suffix = FileUtils.getFileSuffixName(this.path);
		File file = new File(this.path);
		if (file.exists() && file.isFile()) {
			this.length = file.length();
			this.file = file;
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMimeType() {
		return mimeType;
	}

	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}

	public String getNameEncoding() {
		return nameEncoding;
	}

	public void setNameEncoding(String nameEncoding) {
		this.nameEncoding = nameEncoding;
	}

	public File getFile() {
		return file;
	}

	public String getPath() {
		return path;
	}

	public String getSuffix() {
		return suffix;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public long getLength() {
		return length;
	}

	public boolean isDown() {
		return down;
	}

	public void setDown(boolean down) {
		this.down = down;
	}

	public boolean isStream() {
		return stream;
	}

	public void setStream(boolean stream) {
		this.stream = stream;
	}

	public byte[] getBin() {
		return bin;
	}

	public void setBin(byte[] bin) {
		this.bin = bin;
	}

}
